/*
 * @Author: fhw
 * @Date: 2022-07-28 17:19:44
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-12-21 11:37:28
 * @Description:
 */
import { Controller, Get, Post, Body, HttpCode, Query } from '@nestjs/common'
import { ApiResponse, ApiOperation, ApiBody, ApiTags, ApiQuery } from '@nestjs/swagger'
import { DelteIdDto } from '../common/dto/dto'
import { ArticleTagService } from './article_tag.service'
import { ArticleTagDto, CreateTagDto, UpdateCategoryTagDto } from './dto/article_tag.dto'
import { TagResult } from './entities/article_tag.entity'

@Controller('articleTag')
@ApiTags('文章标签')
export class ArticleTagController {
  constructor(private readonly articleTagService: ArticleTagService) {}
  /** 标签 */
  @HttpCode(200)
  @ApiResponse({
    status: 200,
    description: '标签列表',
    type: TagResult,
  })
  @Get('/getArticleTag')
  @ApiOperation({ summary: '获取文章标签', operationId: 'getArticleTag' })
  getArticleTag(@Query() params: ArticleTagDto) {
    return this.articleTagService.getArticleTag(params)
  }
  @HttpCode(200)
  @Post('/createTag')
  @ApiQuery({
    description: '创建标签',
    type: CreateTagDto,
  })
  @ApiBody({
    description: '创建标签',
    type: CreateTagDto,
  })
  @ApiOperation({ summary: '创建标签', operationId: 'createTag' })
  createTag(@Body() body: CreateTagDto) {
    return this.articleTagService.createTag(body)
  }
  @HttpCode(200)
  @Post('/updateTag')
  @ApiQuery({
    description: '更新标签',
    type: UpdateCategoryTagDto,
  })
  @ApiBody({ description: '更新标签', type: UpdateCategoryTagDto })
  @ApiOperation({ summary: '更新标签', operationId: 'updateTag' })
  updateTag(@Body() body: UpdateCategoryTagDto) {
    return this.articleTagService.updateTag(body)
  }
  @HttpCode(200)
  @Post('/delTag')
  @ApiQuery({
    description: '删除标签',
    type: DelteIdDto,
  })
  @ApiBody({ description: 'DelteIdDto', type: DelteIdDto })
  @ApiOperation({ summary: '删除标签', operationId: 'delTag' })
  delTag(@Body() body: DelteIdDto) {
    return this.articleTagService.delTag(body)
  }
}
